﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="采购材料合同录入.aspx.cs" Inherits="syc.Sale.采购材料合同录入" %>
<html>
<head>
<title></title>
<style>
tr{height:30px;}
</style>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
SelectCommand="if not @ID=0
begin
SELECT @编号=t1.编号,@中标ID=t1.中标ID,@材料ID=t1.材料ID,@供货ID=t1.供货ID
,@年度=t1.年度,@季度=t1.季度,@数量=t1.数量,@单价=t1.单价,@长度=t1.长度
,@签订日期=t1.签订日期,@交货时间=t1.交货时间,@运输方式=isnull(t1.运输方式,''),@备注=isnull(t1.备注,''),@交货数量=t1.交货数量
,@交货数量1=t1.交货数量1,@交货数量2=t1.交货数量2,@交货数量3=t1.交货数量3,@交货数量4=t1.交货数量4,@交货数量5=t1.交货数量5
,@交货数量6=t1.交货数量6,@交货数量7=t1.交货数量7,@交货数量8=t1.交货数量8,@交货数量9=t1.交货数量9
,@材料类别=t2.品名,@规格=t2.规格,@供货单位=t3.名称,@单位=t2.单位 FROM 采购材料合同 t1
left outer join 物料品种 t2 on t2.ID=t1.材料ID
left outer join 材料供货单位 t3 on t3.ID=t1.供货ID where t1.ID=@ID;
end
else
begin
select @年度=t2.年度,@季度=t2.季度,@材料ID=t1.材料ID,@材料类别=t3.品名,@规格=t3.规格,@单位=t3.单位
,@供货ID=t1.供货ID,@供货单位=t4.名称,@数量=t1.数量,@单价=t1.单价 from 采购材料中标 t1
left outer join 采购材料标书 t2 on t2.ID=t1.标书ID
left outer join 物料品种 t3 on t3.ID=t1.材料ID
left outer join 材料供货单位 t4 on t4.ID=t1.供货ID
where t1.ID=@中标ID;
end"
InsertCommand="if exists (select id from 采购材料中标 where id=@中标ID and 合同ID=0) begin
insert into 采购材料合同(编号,中标ID,材料ID,供货ID,年度,季度,数量,单价,长度,签订日期,交货时间,运输方式,备注,交货数量
,交货数量1,交货数量2,交货数量3,交货数量4,交货数量5,交货数量6,交货数量7,交货数量8,交货数量9)values(
@编号,@中标ID,@材料ID,@供货ID,@年度,@季度,@数量,@单价,@长度,@签订日期,@交货时间,@运输方式,@备注,@交货数量
,@交货数量1,@交货数量2,@交货数量3,@交货数量4,@交货数量5,@交货数量6,@交货数量7,@交货数量8,@交货数量9);
select @ID=@@IDENTITY;update 采购材料中标 set 合同ID=@ID where ID=@中标ID;end"
UpdateCommand="update 采购材料合同 set 编号=@编号,数量=@数量,单价=@单价
,长度=@长度,签订日期=@签订日期,交货时间=@交货时间
,运输方式=@运输方式,备注=@备注,交货数量=@交货数量
,交货数量1=@交货数量1,交货数量2=@交货数量2,交货数量3=@交货数量3
,交货数量4=@交货数量4,交货数量5=@交货数量5,交货数量6=@交货数量6
,交货数量7=@交货数量7,交货数量8=@交货数量8,交货数量9=@交货数量9 where ID=@ID;"
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    onselected="SqlDataSource1_Selected" oninserted="SqlDataSource1_Inserted">
<SelectParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4" DefaultValue="0" />
<asp:Parameter Name="编号" DbType="AnsiString" Size="20" Direction="Output"/>
<asp:Parameter Name="中标ID" DbType="Int32" Size="4" DefaultValue="0"/>
<asp:Parameter Name="材料ID" DbType="Int32" Size="4" Direction="Output" />
<asp:Parameter Name="供货ID" DbType="Int32" Size="4" Direction="Output" />

<asp:Parameter Name="年度" DbType="Int32" Size="4" Direction="Output" />
<asp:Parameter Name="季度" DbType="Byte" Size="1" Direction="Output"/>
<asp:Parameter Name="数量" DbType="Double"  Size="9" Direction="Output"/>
<asp:Parameter Name="单价" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="长度" DbType="Double"  Size="9" Direction="Output"/>

<asp:Parameter Name="签订日期" DbType="Date"  Size="3" Direction="Output"/>
<asp:Parameter Name="交货时间" DbType="Date"  Size="3" Direction="Output"/>
<asp:Parameter Name="运输方式" DbType="String"  Size="20" Direction="Output"/>
<asp:Parameter Name="备注" DbType="String"  Size="200" Direction="Output"/>
<asp:Parameter Name="交货数量" DbType="Double"  Size="9" Direction="Output"/>

<asp:Parameter Name="交货数量1" DbType="Double"  Size="9" Direction="Output"/>
<asp:Parameter Name="交货数量2" DbType="Double"  Size="9" Direction="Output"/>
<asp:Parameter Name="交货数量3" DbType="Double"  Size="9" Direction="Output"/>
<asp:Parameter Name="交货数量4" DbType="Double"  Size="9" Direction="Output"/>
<asp:Parameter Name="交货数量5" DbType="Double"  Size="9" Direction="Output"/>

<asp:Parameter Name="交货数量6" DbType="Double"  Size="9" Direction="Output"/>
<asp:Parameter Name="交货数量7" DbType="Double"  Size="9" Direction="Output"/>
<asp:Parameter Name="交货数量8" DbType="Double"  Size="9" Direction="Output"/>
<asp:Parameter Name="交货数量9" DbType="Double"  Size="9" Direction="Output"/>
<asp:Parameter Name="材料类别" DbType="String"  Size="40" Direction="Output"/>

<asp:Parameter Name="规格" DbType="String"  Size="40" Direction="Output"/>
<asp:Parameter Name="供货单位" DbType="String"  Size="40" Direction="Output"/>
<asp:Parameter Name="单位" DbType="String"  Size="20" Direction="Output"/>

</SelectParameters>
<InsertParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4" DefaultValue="0" Direction="Output" />
<asp:Parameter Name="编号" DbType="AnsiString" Size="20" />
<asp:Parameter Name="中标ID" DbType="Int32" Size="4" />
<asp:Parameter Name="材料ID" DbType="Int32" Size="4"  />
<asp:Parameter Name="供货ID" DbType="Int32" Size="4"  />

<asp:Parameter Name="年度" DbType="Int32" Size="4" />
<asp:Parameter Name="季度" DbType="Byte" Size="1" />
<asp:Parameter Name="数量" DbType="Decimal" Size="9" />
<asp:Parameter Name="单价" DbType="Currency" Size="8" />
<asp:Parameter Name="长度" DbType="Decimal"  Size="9" />

<asp:Parameter Name="签订日期" DbType="Date"  Size="3" />
<asp:Parameter Name="交货时间" DbType="Date"  Size="3" />
<asp:Parameter Name="运输方式" DbType="String"  Size="20" />
<asp:Parameter Name="备注" DbType="String"  Size="200" />
<asp:Parameter Name="交货数量" DbType="Decimal"  Size="9" />

<asp:Parameter Name="交货数量1" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量2" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量3" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量4" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量5" DbType="Decimal"  Size="9" />

<asp:Parameter Name="交货数量6" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量7" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量8" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量9" DbType="Decimal"  Size="9" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4" DefaultValue="0" />
<asp:Parameter Name="编号" DbType="AnsiString" Size="20" />
<asp:Parameter Name="数量" DbType="Decimal" Size="9" />
<asp:Parameter Name="单价" DbType="Currency" Size="8" />
<asp:Parameter Name="长度" DbType="Decimal"  Size="9" />

<asp:Parameter Name="签订日期" DbType="Date"  Size="3" />
<asp:Parameter Name="交货时间" DbType="Date"  Size="3" />
<asp:Parameter Name="运输方式" DbType="String"  Size="20" />
<asp:Parameter Name="备注" DbType="String"  Size="200" />
<asp:Parameter Name="交货数量" DbType="Decimal"  Size="9" />

<asp:Parameter Name="交货数量1" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量2" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量3" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量4" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量5" DbType="Decimal"  Size="9" />

<asp:Parameter Name="交货数量6" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量7" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量8" DbType="Decimal"  Size="9" />
<asp:Parameter Name="交货数量9" DbType="Decimal"  Size="9" />
</UpdateParameters>
</asp:SqlDataSource>

<asp:Label ID="HTID" runat="server" Text="0" Visible="false"></asp:Label>
<asp:Label ID="ZBID" runat="server" Text="0" Visible="false"></asp:Label>
<asp:Label ID="LBID" runat="server" Text="0" Visible="false"></asp:Label>
<asp:Label ID="GHID" runat="server" Text="0" Visible="false"></asp:Label>
<asp:Label ID="NianDu" runat="server" Text="0" Visible="false"></asp:Label>
<asp:Label ID="JiDu" runat="server" Text="0" Visible="false"></asp:Label>
<asp:Label ID="DanWei" runat="server" Text="0" Visible="false"></asp:Label>

<%if (Request.QueryString["id"] == null)
  { %>
<div id="wintop" class="wintop" style="display:none;">辅料采购合同录入</div>
<%}%>
<%if (Request.QueryString["id"] != null)
  { %>
<div id="wintop" class="wintop" style="display:none;">辅料采购合同修改</div>
<%}%>

<asp:Panel ID="Panel1" runat="server" CssClass="panel">
<asp:Button ID="Button_Save" runat="server" Text="保 存" UseSubmitBehavior="false" 
        CssClass="button" onclick="Button_Save_Click"  />

<%if (Request.QueryString["bid"] == null)
  { %>   
<asp:Button ID="Button_Cancel" runat="server" Text="返 回" UseSubmitBehavior="false"  Visible="false"
        CssClass="button" />
     <%} %>
        
    
<asp:Button ID="Button_Close" runat="server" Text="关 闭" UseSubmitBehavior="false"  Visible="true"
        CssClass="button" OnClientClick="parent.swin2_close();return false;" />
</asp:Panel>

<asp:Panel ID="Panel_Msg" runat="server" CssClass="panel2">
    <asp:Label ID="Message" runat="server" Text="·" CssClass="prompt"></asp:Label>
</asp:Panel>

<asp:Panel ID="Panel2" runat="server" CssClass="panel" HorizontalAlign="Center">

<table border=1 style="border-collapse:separate;font-size:14px;margin-bottom:6px;">
<tr>
<td colspan=6 align=center style="font-weight:bold; letter-spacing:10px;font-size:16px;border:none;">合同信息</td>
</tr>
<tr>
<td width=85 align=right>合同编号:</td>
<td width=130><asp:TextBox ID="BianHao" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
<td width=100 align=right>年度季度:</td>
<td width=130><asp:Label ID="NianJiDu" runat="server" Text=""></asp:Label>&nbsp;</td>
<td width=85 align=right>签订日期:</td>
<td width=140><asp:TextBox ID="Date1" runat="server" CssClass="textbox" Width="120"></asp:TextBox><img alt="" src="/Icons/29.png" align="absmiddle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" /></td>
</tr>
<tr>
<td align=right>辅料类别:</td>
<td><asp:Label ID="LeiBie" runat="server" Text=""></asp:Label>&nbsp;</td>
<td align=right>规 格:</td>
<td><asp:Label ID="GuiGe" runat="server" Text=""></asp:Label>&nbsp;</td>
<td align=right>交货时间:</td>
<td><asp:TextBox ID="Date2" runat="server" CssClass="textbox" Width="120"></asp:TextBox><img alt="" src="/Icons/29.png" align="absmiddle" onclick="makecalendar(document.getElementById('Date2').value, document.getElementById('Date2'));" /></td>
</tr>
<tr>
<td align=right>供货单位:</td>
<td><asp:Label ID="GongHuo" runat="server" Text=""></asp:Label>&nbsp;</td>
<td align=right>数量(<%=this.DanWei.Text %>):</td>
<td><asp:TextBox ID="ShuLiang" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
<td align=right>单价(元):</td>
<td><asp:TextBox ID="DanJia" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
</tr>
<tr>
<td align=right>长度(米):</td>
<td>    <asp:Label ID="ChangDu" runat="server" Text="——"></asp:Label>
</td>
<td align=right>交货数量(<%=this.DanWei.Text %>):</td>
<td><asp:TextBox ID="JiaoHuo" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
<td align=right>运输方式:</td>
<td><asp:TextBox ID="YunShu" runat="server" CssClass="textbox" Width="120" Text="汽车运输"></asp:TextBox></td>
</tr>
<tr>
<td align=right>备 注:</td>
<td colspan=5><asp:TextBox ID="BeiZhu" runat="server" CssClass="textbox" Width="358"></asp:TextBox></td>
</tr>
</table>

</asp:Panel>

</form>

<script >
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }

    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName != "INPUT" || tag.className != "textbox") return;
        if (tag.id == "JiaoHuo9") return;
        if (e.keyCode == 13) e.keyCode = 9;
    }
    function makecalendar(d, o) {
        obj = o;
        idate = makedate(d);
        cdate = new Date(idate.getFullYear(), idate.getMonth(), 1);
        ds.style.left = (getObjectLeft(o) - 74) + "px";
        ds.style.top = (getObjectTop(o) + 22) + "px";
        ds.style.display = 'block';
        showcalendar();
    }
</script>
</body>
</html>
